<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>礼品订单</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../script/jquery-1.4.4.min.js"></script>
</head>
<body>
	<div class="container">
        <div class="flow">
            <div class="itemtitle">
                <h3>礼品订单</h3>
                <ul>
                    <li <{if $smarty.get.operation=='' and $smarty.get.type==''}>class="current"<{/if}>><a href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>"><span>管理</span></a></li>
                    <li <{if $smarty.get.type=='10'}>class="current"<{/if}>><a href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>&type=10"><span>未发货</span></a></li>
                    <li <{if $smarty.get.type=='20'}>class="current"<{/if}>><a href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>&type=20"><span>已发货</span></a></li>
                    <li <{if $smarty.get.type=='30'}>class="current"<{/if}>><a href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>&type=30"><span>已完成</span></a></li>
                    <li <{if $smarty.get.type=='0'}>class="current"<{/if}>><a href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>&type=0"><span>已取消</span></a></li>
                    
                    <{if $smarty.get.operation=='edit'}>
                    <li class="current"><a href="#"><span>操作</span></a></li>
                    <{/if}>
                </ul>
            </div>
        </div>
        <div class="h35"></div>  
        <{if $smarty.get.operation=='edit' }>
            <table class="table table1">
                <thead>
                    <tr>
                        <th class="partition" colspan="99">订单详情</th>
                    </tr>
                </thead>
                <tbody>
                <tr class="tr">
                    <td width="50">订单状态</td>
                    <td width="100"><b class="org"><{assign var=val value=$de.status}><{$statu_list.$val}></b></td>
                
                    <td width="50">订单编号</td>
                    <td width="100"><{$de.order_id}></td>
                    
                    <td width="50">下单时间</td>
                    <td><{$de.create_time|date_format:"%Y-%m-%d&nbsp;%H:%M:%S"}></td>
                </tr>
                </tbody>
            </table>
            <table class="table table1">    
                <thead>
                    <tr>
                        <th class="partition" colspan="99">订单信息</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                    	<td></td>
                        <td>产品</td>
                        <td width="300">所需积分</td>
                    </tr>
                    <tr>
                        <td width="90"><a target="_blank" href="../?m=points&s=detail&id=<{$de.tg_id}>"><img width="80" src="<{$de.pic}>"></a></td>
                        <td><a target="_blank" href="../?m=points&s=detail&id=<{$de.product_id}>"><{$de.product_name}></a></td>
                        <td>&nbsp;<{$de.allpoint}></td>
                    </tr>
                    <tr>
                    	<td colspan="99">下单时间:<{$de.create_time|date_format:"%Y-%m-%d&nbsp;%H:%M:%S"}></td>
                    </tr>
                    <{if $de.shipping_time}>
                    <tr>
                    	<td colspan="99">发货时间:<{$de.shipping_time|date_format:"%Y-%m-%d&nbsp;%H:%M:%S"}></td>
                    </tr>
                    <{/if}>
                    <{if $de.finnshed_time}>
                    <tr>
                    	<td colspan="99"><{if $de.status==0}>取消时间<{else}>完成时间<{/if}>:<{$de.finnshed_time|date_format:"%Y-%m-%d&nbsp;%H:%M:%S"}> <{if $de.admin_remark}>取消原因：<{$de.admin_remark}><{/if}></td>
                    </tr>
                    <{/if}>
                </tbody>
            </table>
            <table class="table table1">         
                <thead>
                    <tr>
                        <th class="partition" colspan="99">收货地址</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td width="100">收货人</td>
                        <td><{$de.contact}></td>
                    </tr>
                    <tr>
                        <td>联系电话</td>
                        <td><{$de.tel}></td>
                    </tr>
                    <tr>
                        <td>收货地址</td>
                        <td><{$de.address}></td>
                    </tr>
                </tbody>
            </table>
            <{if $de.status>10 || ( $de.status==10 && $de.shipping_code )}>
            <table class="table table1">         
                <thead>
                    <tr>
                        <th class="partition" colspan="99">发货地址</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td width="100">发货人</td>
                        <td><{$de.shipping_name}></td>
                    </tr>
                    <tr>
                        <td>联系电话</td>
                        <td><{$de.shipping_tel}></td>
                    </tr>
                    <tr>
                        <td>发货地址</td>
                        <td><{$de.shipping_address}></td>
                    </tr>
                </tbody>
            </table>
            <table class="table table1">         
                <thead>
                    <tr>
                        <th class="partition" colspan="99">物流信息</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td width="100">物流名称</td>
                        <td><{$de.shipping_company}></td>
                    </tr>
                    <tr>
                        <td>物流单号</td>
                        <td><{$de.shipping_code}></td>
                    </tr>
                </tbody>
            </table>
            <{/if}>
            
            <{if $de.status==10}>
            <script type="text/javascript" charset="utf-8" src="../script/district.js" ></script>
            <script language="javascript">
            var weburl="<{$config.weburl}>";
            </script>
            <form name="form" id="form" method="post">
            <input name="id" type="hidden" id="id" value="<{$de.id}>">
            <table class="table table1">
            	<thead>
                    <tr>
                        <th class="partition" colspan="99">发货地址</th>
                    </tr>
                </thead>
                <tbody>
                <tr>
                    <td width="100">发货人</td>
                    <td><input name="shipping_name" type="text" id="shipping_name" /></td>
                </tr>
                <tr>
                    <td rowspan="2" width="100">发货地址</td>
                    <td>
                    <input type="hidden" name="t" id="t" value="" />
                    <input type="hidden" name="province" id="id_1" value="" />
                    <input type="hidden" name="city" id="id_2" value="" />
                    <input type="hidden" name="area" id="id_3" value="" />
                   
                    <select name="select_1" id="select_1" onChange="district(this);">
                    <option value="">--请选择--</option>
                    <{$district}>
                    </select>
                    <select name="select_2" id="select_2" onChange="district(this);" class="hidden"></select>
                    <select name="select_3" id="select_3" onChange="district(this);" class="hidden"></select>
                    </td>
                </tr>
                <tr>
                    <td>
                    <input name="shipping_address" type="text" id="shipping_address" class="w350" />
                    </td>
                </tr>
                <tr>
                    <td width="100">联系电话</td>
                    <td><input name="shipping_tel" type="text" id="shipping_tel" /></td>
                </tr>
                </tbody>
            </table>
            <table class="table table1">
            	<thead>
                    <tr>
                        <th class="partition" colspan="99">物流信息</th>
                    </tr>
                </thead>
                <tbody>
                <tr>
                    <td width="100">物流名称</td>
                    <td width="350">物流单号</td>
                    <td></td>
                </tr>
                <{foreach item=list from=$re}>
                <tr>
                    <td><{$list.company}></td>
                    <td class="tl"><input type="text" class="text w300" name="shipping_code" value="" values="<{$list.id}>" data_type="send"></td>
                    <td><a class="btn2" href="javascript:void(0);" values="<{$list.id}>" values1="<{$list.company}>" data_type="send">确认</a></td>
                </tr>
                <{/foreach}>
                </tbody>
            </table>
            <input name="act" type="hidden" id="action" value="shipping">
            <input name="shipping_company" type="hidden" id="shipping_company" value="">
            </form>
            <script>
			$('a[data_type="send"]').live('click',function(){
				if ($('input[values="'+$(this).attr('values')+'"]').val() == ''){
					alert('请填写物流单号！');return false;
				}
				if ($('input[name="shipping_name"]').val() == ''){
					alert('请填写发货人！');return false;
				}
				if ($('select[name="select_1"]').val() == ''){
					alert('请填省市区！');return false;
				}
				if ($('select[name="select_2"]').val() == ''){
					alert('请填省市区！');return false;
				}
				if ($('select[name="select_3"]').val() == ''){
					alert('请填省市区！');return false;
				}
				if ($('input[name="shipping_address"]').val() == ''){
					alert('请填发货地址！');return false;
				}
				if ($('input[name="shipping_tel"]').val() == ''){
					alert('请填写联系电话！');return false;
				}
				$('input[data_type="send"]').attr('disabled',true);
				$('input[values="'+$(this).attr('values')+'"]').attr('disabled',false);
				$('#shipping_company').val($(this).attr('values1'));
				$('#form').submit();
			});
			</script> 
            <{/if}>
            
            <{if $de.status}>
            <form name="form1" id="form1" method="post">
            <input name="id" type="hidden" id="id" value="<{$de.id}>">
            <input name="order_id" type="hidden" id="order_id" value="<{$de.order_id}>">
            <input name="points" type="hidden" id="points" value="<{$de.allpoint}>">
            <input name="buid" type="hidden" id="buid" value="<{$de.buyer_id}>">
            <table class="table table1">
            	<thead>
                    <tr>
                        <th class="partition" colspan="99">取消订单</th>
                    </tr>
                </thead>
                <tbody>
                <tr>
                    <td width="100" valign="top"><div class="mt10">取消缘由</div></td>
                    <td>
                    <ul class="cancel">
                        <li>
                            <input type="radio" value="无法备齐货物" id="d1" name="admin_remark" checked="">
                            <label for="d1">无法备齐货物</label>
                        </li>
                        <li>
                            <input type="radio" value="不是有效的订单" id="d2" name="admin_remark">
                            <label for="d2">不是有效的订单</label>
                        </li>
                        <li>
                            <input type="radio" value="买家主动要求" id="d3" name="admin_remark">
                            <label for="d3">买家主动要求</label>
                        </li>
                        <li>
                            <input type="radio" value="其他原因" id="d4" flag="other_reason" name="admin_remark">
                            <label for="d4">其他原因</label>
                        </li>
                        <li style="display:none; height:48px;" id="other_reason">
                        	<textarea class="w300" rows="2" name="other_reason"></textarea>
                        </li>
                    </ul>
                    </td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td>
                    <input class="submit" onclick="return confirm('您确实要取消该订单吗');" type="submit" value="取消订单">
                    <input name="act" type="hidden" id="action" value="cancel">
                    </td>
                </tr>
                </tbody>
			</table>
            <{/if}>
            </form>
            <script type="text/javascript">
			$(function(){
				$("input[name='admin_remark']").click(function(){
					if ($(this).attr('flag') == 'other_reason')
					{
						$('#other_reason').show();
					}
					else
					{
						$('#other_reason').hide();
					}
				});
			});
			</script>
        <{else}>
        <table class="table">
            <tbody>
                <tr class="header">
                    <th width="180" class="al">&nbsp;订单编号</th>
                    <th width="120">买家名称</th>
                    <th>产品</th>
                    <th width="150">所需积分</th>
                    <th width="150">下单时间</th>
                    <th width="70">订单状态</th>
                    <th width="50"></th>
                </tr>
                <{foreach item=list from=$de.list}>
                <tr>
                    <td class="al">&nbsp;<a href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>&operation=edit&editid=<{$list.id}>" ><{$list.order_id}></a></td>
                    <td><a target="_blank" href="../home.php?uid=<{$list.buyer_id}>"><{$list.buyer_name}></a></td>
                    <td><a target="_blank" href="../?m=points&s=detail&id=<{$list.product_id}>"><{$list.product_name}></a></td>
                    <td>&nbsp;<{$list.allpoint}></td>
                    <td><{$list.create_time|date_format:"%Y-%m-%d&nbsp;%H:%M:%S"}></td>
                    <td><{assign var=val value=$list.status}><{$statu_list.$val}></td>
                    <td>
                    <a href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>&operation=edit&editid=<{$list.id}>"><{$setimg}></a> 
                    </td>
                </tr>
                <{foreachelse}>
                <tr>
                    <td class="norecord" colspan="99"><i></i><span>暂无符合条件的数据记录</span></td>
                </tr>
                <{/foreach}>
            </tbody>
            <tfoot>
                <tr>
                	<td colspan="3"></td>
                    <td colspan="99"><div class="page"><{$de.page}></div></td>
                </tr>
            </tfoot>
        </table>
        <{/if}>
    </div>
</body>
</html>